﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntitiesLayer;
using System.Transactions;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using System.IO;

namespace DAL.Repositorios
{
    public class ConstantesReadOnlyRepository : IRepositoryByKey<string, IList<string>>
    {
       
       

        public IList<string> List(string Key)
        {
            if ("Telefono".Equals(Key)) return contanteTipoTelefono();

            if ("Id".Equals(Key)) return constanteTipoId();

            if ("Pais".Equals(Key)) return ConstantePaises();

            if ("Correo".Equals(Key)) return contanteTipoCorreo();

            if ("Pliegue".Equals(Key)) return constanteTipoPliegue();
            
            if ("Perimetro".Equals(Key)) return constanteTipoPerimetro();

            return null;
        }


        private IList<string> constanteTipoId(){

            IList<string> lista = new List<string>();
            DataSet ds= getDataSet("PaListarConstanteTipoId");

            foreach (DataRow dr in ds.Tables[0].Rows)
                lista.Add(dr.Field<string>("DescTipoID"));

            return lista.Count > 0 ? lista : null;
        
        }

        private IList<string> constanteTipoPliegue() {

            return null;
        }


        private IList<string> constanteTipoPerimetro() {

            return null;
        }

        private IList<string> ConstantePaises()
        {

            IList<string> lista = new List<string>();
            DataSet ds = getDataSet("PaListarConstantePaises");

            foreach (DataRow dr in ds.Tables[0].Rows)
                lista.Add(dr.Field<string>("NombrePais"));

            return lista.Count > 0 ? lista : null;

        }
        
        private IList<string> contanteTipoTelefono()
        {

            IList<string> lista = new List<string>();
            DataSet ds = getDataSet("PaListarConstanteTipoTelefono");

            foreach (DataRow dr in ds.Tables[0].Rows)
                lista.Add(dr.Field<string>("DescTipoTelefono"));

            return lista.Count > 0 ? lista : null;

        }

          private IList<string> contanteTipoCorreo()
        {

            IList<string> lista = new List<string>();
            DataSet ds = getDataSet("PaListarConstanteTipoCorreo");

            foreach (DataRow dr in ds.Tables[0].Rows)
                lista.Add(dr.Field<string>("DescTipoCorreo"));

            return lista.Count > 0 ? lista : null;

        }


   
        public DataSet getDataSet(string pa) {

            SqlCommand cmd = new SqlCommand();
            DataSet ds = DBAccess.ExecuteSPWithDS(ref cmd, pa);
            return ds;
        }
    }
}
